/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.admin.controller;

import com.admin.model.EmployeeFacadeLocal;
import com.admin.model.EventRegistrationFacadeLocal;
import com.common.json.JsonModel;
import com.entities.Employee;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 *
 * @author Tuan Long
 */
@Stateless
public class EmployeeManager implements EmployeeManagerRemote {
    @EJB
    private EventRegistrationFacadeLocal eventRegistrationFacade;
    @EJB
    private EmployeeFacadeLocal employeeFacade;

    @Override
    public String getEmployeeInfoById(String username) {
        Employee employee = employeeFacade.find(username);
        String json = JsonModel.getJsonEmployeeInfoSender(employee);
        return ""+json;
    }

    @Override
    public boolean ChangeEmployeePassword(String username, String password) {
        return employeeFacade.changeEmployeePassword(username, password);
    }

    @Override
    public List<String> getAllEmployee() {
        List<String> listJson = new ArrayList<String>();
        List<Employee> employees = employeeFacade.findAll();
        for (Employee employee : employees) {
            String json = JsonModel.getJsonEmployeeInfoSender(employee);
            listJson.add(json);
        }
        return listJson;
    }

    @Override
    public List<String> getRegisters(int eventId) {        
        return eventRegistrationFacade.getRegisters(eventId);
    }
    
    
    
    
}
